#include<stdio.h>

int main(void)
{
    int a = 0;
    long p = 1;
    int sum = 0;

    printf("please input :\n");
    int ret = scanf_s("%d", &a);
    while (ret != 1 || a < 1 || a>20)
    {

        while (getchar() != '\n');
        printf("ret error!\n");
        ret = scanf_s("%d", &a);
        continue;

    }
    for (int i = 1; i <= a; i++)
    {
        p = p * i;
        sum = sum + p;


    }

    printf("sum=%ld", sum%1000000);
    return 0;
}